<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center releaseDynamic_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center flex-sub releaseDynamic_fd0_0'>
					<view class='flex flex-wrap align-center releaseDynamic_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  releaseDynamic_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center releaseDynamic_fd0_0_c1'
						@tap.stop="popupShow1698300968385=true">
						<image class='releaseDynamic_fd0_0_c1_c0' mode="aspectFit" :src='STATIC_URL+"704.png"'></image>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="loading_css" v-if="isShow">
				<u-loading size="36" color="#AD3823"></u-loading>
				<view>加载中</view>
			</view>
			<block v-else>
				<!---flex布局flex布局开始-->
				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
					<view class='flex flex-wrap align-center releaseDynamic_fd1_0'>
						<block v-if="data_type == 1">
							<benben-images-upload ref="benbenImagesUploadfd1_0_c0" :is-show-tips='true' :maxlength="9"
								:img-ids.sync="img_id" :img-list.sync="imagesList">
								<template #content="{ num, maxlength, isShow, imgList }">
									<view class="flex flex-wrap align-start flex releaseDynamic_fd1_0_c0">

										<view v-for="(image, index) in imgList" :key="index"
											class='flex position-relative releaseDynamic_fd1_0_c00'>
											<text class='fu-iconfont2 position-absolute releaseDynamic_fd1_0_c000'
												@tap.stop="$refs.benbenImagesUploadfd1_0_c0.delImage(index)">&#xE8E7;</text>
											<image class='releaseDynamic_fd1_0_c001'
												@tap.stop="$refs.benbenImagesUploadfd1_0_c0.previewImage(index)"
												mode="aspectFill" :src='image'></image>
										</view>

										<image class='releaseDynamic_fd1_0_c01'
											@tap.stop="$refs.benbenImagesUploadfd1_0_c0.manyChooseImage()" v-if="isShow"
											mode="aspectFill" :src='STATIC_URL+"561.png"'></image>
										<text class='image_upload_tips releaseDynamic_fd1_0_c02'
											style="font-family: PingFang SC, PingFang SC;">最多上传{{num}}/{{maxlength}}张图片</text>
									</view>
								</template>
							</benben-images-upload>
						</block>
						<block v-if="data_type == 2">
							<benben-video-upload-paas ref="upload1697868577140" isShowClean='true'
								:video-info.sync="videoInfo">
								<template v-slot="{src, poster}">
									<view class='flex position-relative releaseDynamic_fd1_0_c1'>
										<image class='releaseDynamic_fd1_0_c001' mode="aspectFill"
											@tap="$refs.upload1697868577140.previewVideo()"
											:src='poster?poster:STATIC_URL+"561.png"'></image>

										<text class='fu-iconfont2 position-absolute releaseDynamic_fd1_0_c000'
											@tap="$refs.upload1697868577140.delVideo()" v-if="src">&#xE8E7;</text>

									</view>
								</template>
							</benben-video-upload-paas>
						</block>

					</view>
				</view>

				<!---flex布局flex布局结束-->
				<!---flex布局flex布局开始-->
				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout releaseDynamic_flex_2">
					<view class='flex flex-wrap align-center releaseDynamic_fd2_0'>
						<!-- <text class='releaseDynamic_fd2_0_c0'>填写标题会有更多赞哦~</text> -->
						<input style="width: 100%;color: #333;font-size: 40rpx;" v-model="title" type="text"
							:maxlength="30" placeholder="填写标题会有更多赞哦~"
							placeholder-style="color: #333;font-size: 40rpx;font-family: PingFang SC, PingFang SC;">
					</view>
					<view class='flex flex-wrap align-center releaseDynamic_fd2_1'>
						<view class='flex flex-wrap releaseDynamic_fd2_1_c0'>
							<textarea class='flex releaseDynamic_input_fd2_1_c0' :placeholder="'添加正文'" :maxlength="300"
								placeholder-style="color:#999;font-size:32rpx;font-family: PingFang SC, PingFang SC;"
								v-model="fd2_1_c0" />

						</view>
					</view>
					<view class='flex flex-wrap align-center'>
						<image class='releaseDynamic_fd2_2_c0' mode="aspectFit" :src='STATIC_URL+"562.png"'></image>
						<text class='releaseDynamic_fd2_2_c1'
							style="font-family: PingFang SC, PingFang SC;">{{name}}</text>
					</view>
				</view>
			</block>



			<!---flex布局flex布局结束-->
			<benben-popup v-model="popupShow1698300968385" :mask="true" :mask-close-able="true" mode='center'
				:z-index='999'>
				<!---flex布局flex布局开始-->
				<view class="flex benben-flex-layout flex-wrap align-center">
					<view class='flex flex-direction flex-wrap align-stretch releaseDynamic_fd3_0'>
						<scroll-view class="releaseDynamic_fd3_0_c0_c0" :scroll-y="true">
							<u-parse class='releaseDynamic_fd3_0_c0_c0_c0' :html="fabu_content">
							</u-parse>
						</scroll-view>
						<button class='releaseDynamic_fd3_0_c1' style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;" @tap.stop="popupShow1698300968385=false">知道了</button>
						<view class='flex flex-wrap align-center releaseDynamic_fd3_0_c2'
							@tap.stop="popupShow1698299746187=false">
						</view>
					</view>
				</view>

				<!---flex布局flex布局结束-->

			</benben-popup>
			<view class="flex flex-wrap align-center justify-center benben-position-layout flex releaseDynamic_flex_4">
				<button class='releaseDynamic_fd4_0' style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;" @tap.stop="fabu">发布</button>

			</view>
			<view :style="{height: '128rpx'}"></view>
		</view>
	</view>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				"popupShow1698300968385": false,
				"title": "",
				"fd2_1_c0": "",
				"imagesList": [],
				"img_id": "",
				"videoInfo": {
					path: "",
					path_img: ""
				},
				"data_type": "1", //数据类型：1=图文，2=视频
				"id": "", // 心得id
				"fabu_content": "", // 发布规则 
				"isShow": false,
				"name": "",
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				course_id,
				id,
				data_type
			} = options;
			if (course_id !== undefined) this.course_id = course_id;
			if (id !== undefined) this.id = id;
			if (data_type !== undefined) this.data_type = data_type;
			this.getRule();
			this.getCategoryInfo();
			if (this.id) {
				this.isShow = true;
				this.getDetails();
			}
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 阶段课程信息
			getCategoryInfo() {
				this.$api.post(global.API_VERSION + '6584fa8b8d35b', {
					course_id: this.course_id
				}).then(res => {
					this.isShow = false;
					if (res.data.code == 1) {
						this.name = res.data.data.name || "";
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},

			// 心得详情
			getDetails() {
				this.$api.post(global.API_VERSION + '6552133d329a3', {
					community_id: this.id
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.data_type = res.data.data.data_type;
						if (this.data_type == 1) {
							this.imagesList = res.data.data.images;
							this.title = res.data.data.title;
							this.fd2_1_c0 = res.data.data.content;
						} else if (this.data_type == 2) {
							this.videoInfo.path = res.data.data.video;
							this.videoInfo.path_img = res.data.data.video_img;
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 发布规则
			getRule() {
				this.$api.post(global.API_VERSION + '63a6ac771882e', {
					aid: 8
				}).then(res => {
					if (res.data.code == 1) {
						this.fabu_content = res.data.data.content;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 编辑/发布心得  655213003980c
			fabu() {
				if (this.data_type == 1) {
					if (this.imagesList.length == 0) {
						this.$message.info('请上传图片');
						return;
					}

				} else if (this.data_type == 2) {
					if (!this.videoInfo.path) {
						this.$message.info('请上传视频');
						return;
					}
				}
				if (!this.title) {
					this.$message.info('请输入标题');
					return;
				}
				if (!this.fd2_1_c0) {
					this.$message.info('请输入内容');
					return;
				}
				this.$api.post(global.API_VERSION + '655213003980c', {
					course_id: this.course_id,
					title: this.title,
					content: this.fd2_1_c0,
					images: this.imagesList.length > 0 ? this.imagesList.join(',') : "",
					video: this.videoInfo.path,
					data_type: this.data_type,
					community_id: this.id
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						setTimeout(() => {
							uni.navigateBack();
						}, 800)
					}
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor1);
		background-size: 100% auto;
	}

	.releaseDynamic_flex_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/480.png) no-repeat;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.releaseDynamic_fd0_0_c1_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.releaseDynamic_fd0_0_c1 {
		margin: 0rpx 0rpx 0rpx 350rpx;
	}

	.releaseDynamic_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.releaseDynamic_fd0_0_c0 {
		width: 120rpx;
	}

	.releaseDynamic_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.releaseDynamic_fd1_0_c1 {
		margin: 0rpx 0rpx 38rpx 0rpx;
	}

	.releaseDynamic_fd1_0_c02 {
		font-size: 24rpx;
		color: #BFBFBF;
		font-weight: 400;
		margin: 0rpx 0rpx 38rpx 0rpx;
		width: 600rpx;
	}

	.releaseDynamic_fd1_0_c01 {
		width: 164rpx;
		height: 164rpx;
		margin: 0rpx 24rpx 24rpx 0rpx;
	}

	.releaseDynamic_fd1_0_c001 {
		width: 164rpx;
		height: 164rpx;
		border-radius: 8rpx;
	}

	.releaseDynamic_fd1_0_c000 {
		top: 0rpx;
		right: 0rpx;
		z-index: 10;
		color: #ff5536;
	}

	.releaseDynamic_fd1_0_c00 {
		margin: 0rpx 24rpx 24rpx 0rpx;
	}

	.releaseDynamic_fd1_0_c0 {
		width: 688rpx;
		padding: 24rpx 0rpx 0rpx 0rpx;
	}

	.releaseDynamic_fd1_0 {
		background: #FFFFFF;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		padding: 40rpx 30rpx 0rpx 30rpx;
	}

	.releaseDynamic_flex_2 {
		background: var(--benbenbgColor1);
		background-size: 100% auto;
		padding: 0rpx 30rpx 0rpx 30rpx;
	}

	.releaseDynamic_fd2_2_c1 {
		color: #333333;
		font-size: 34rpx;
		font-weight: 400;
		margin: 0rpx 0rpx 0rpx 16rpx;
	}

	.releaseDynamic_fd2_2_c0 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.releaseDynamic_input_fd2_1_c0 {
		width: 100%;
		height: 500rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
		white-space: pre-wrap;
	}

	.releaseDynamic_fd2_1_c0 {
		background: var(--benbenbgColor1);
		width: 684rpx;
		padding: 35rpx 0rpx 0rpx 0rpx;
	}

	.releaseDynamic_fd2_1 {
		padding: 0rpx 0rpx 0rpx 0rpx;
	}

	.releaseDynamic_fd2_0_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
	}

	.releaseDynamic_fd2_0 {
		border-bottom: 1px solid #eee;
		padding: 0rpx 0rpx 40rpx 0rpx;
	}

	.releaseDynamic_fd3_0_c2 {
		width: 50rpx;
		height: 50rpx;
		position: absolute;
		right: 0rpx;
		top: 7rpx;
	}

	.releaseDynamic_fd3_0_c1 {
		background: linear-gradient(165deg, #BB4833 0%, #962F1D 100%);
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 415rpx;
		line-height: 54rpx;
		font-size: 24rpx;
		color: #fff;
		height: 54rpx;
		box-shadow: 5rpx 4rpx 4rpx 1rpx rgba(161, 55, 35, 0.16);
		font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;
	}

	.releaseDynamic_fd3_0_c0_c2_c0 {
		color: #AD3823;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 34rpx;
	}

	.releaseDynamic_fd3_0_c0_c2 {
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.releaseDynamic_fd3_0_c0_c0_c0 {
		color: #AD3823;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 44rpx;
	}

	.releaseDynamic_fd3_0_c0_c0 {
		// margin: 0rpx 0rpx 34rpx 0rpx;
		width: 100%;
		height: 310rpx;
		margin-bottom: 20rpx;
		padding: 0 16rpx 0 8rpx;
	}

	.releaseDynamic_fd3_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/703.png) no-repeat;
		width: 646rpx;
		height: 513rpx;
		background-size: 100% auto;
		padding: 60rpx 38rpx 0rpx 165rpx;
	}

	.releaseDynamic_flex_4 {
		width: 750rpx;
		height: 128rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.releaseDynamic_fd4_0 {
		background: var(--benbenbgColor2);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		width: 690rpx;
		line-height: 88rpx;
		font-size: 36rpx;
		color: #fff;
		height: 88rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
	}
</style>

<style>
	page {
		font-family: Alimama DongFangDaKai;
	}
</style>